package com.lujianfei.powersearch.widget

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.FrameLayout
import android.widget.TextView
import com.lujianfei.powersearch.R
import com.lujianfei.powersearch.utils.ResUtils

class BreadCrumbsItem @JvmOverloads constructor(
        context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {

    var txt_info: TextView? = null

    init {
        LayoutInflater.from(context).inflate(R.layout.widget_breadcrumbs_item, this, true)
        txt_info = findViewById(R.id.txt_info)
    }

    fun setTextInfo(textInfo: String?) {
        txt_info?.text = textInfo
    }

    fun hideArrow() {
        txt_info?.setCompoundDrawables(null, null, null, null)
        txt_info?.setTextColor(ResUtils.getColor(R.color.currentItem))
    }

    fun showArrow() {
        val drawable = ResUtils.getDrawable(R.drawable.ic_go)
        drawable.setBounds(0, 0, drawable.intrinsicWidth, drawable.intrinsicHeight)
        txt_info?.setCompoundDrawables(null, null, drawable, null)
        txt_info?.setTextColor(ResUtils.getColor(R.color.bread_crumbs_text_color))
    }
}